<?php
/***************************************************************************
 *                           pilotemail_submit.php
 *                            -------------------
 *                       (APU) Automated Pilot Utility
 *   begin                : Sunday Nov 26, 2006
 *   copyright            : (C) 2004-2006 SF Games
 *   email                : techsupport@sf-games.com
 ****************************************************************************/
 
 	include('include/common.php');
 	include('include/config.php');
	include('include/dbcommon.php');

	// Snag the pilot ID given
	$emailPilotID = stripslashes($_GET['id']);

	htmlHeader();
	vaTable($vaName);

	$db = mysql_connect($dbhost, $dbuname, $dbpass)
		or die("Error: in pirep_submit.php. Could not connect to the SQL server " .mysql_error());
	mysql_select_db($dbname);

	$query  = 'SELECT PILOT_ID, FIRST_NAME, LAST_NAME, EMAIL FROM ' .$table_prefix .'PILOTS WHERE PILOT_ID = ' .sqlfix($emailPilotID);
	$result = mysql_query($query);
	if ( !$result )
		die("Error: in updatePilot() from pirep_submit.php. Query for Pilot ID in table PILOTS failed. " .mysql_error());
	$pilot = mysql_fetch_array($result, MYSQL_ASSOC);

	displayEmailForm($pilot);
 	htmlFooter();
 
?>
 
 
<?php
 
 			//////////////////////////////////////////////////
 			//                                              //
 			//             Support Functions                //
 			//                                              //
 			//////////////////////////////////////////////////
 
 //
 // Display rosters HTML header
 //
 function htmlHeader()
 {
 	echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
 	echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
 	echo "<head>\n";
 	echo "<title>APU E-mail Pilot</title>\n";
 	include_once('include/header.php');
 	echo "</head>\n";
 	echo "<body>\n";
 	echo "<div align=\"center\">\n";
 }
 
 //
 // Display the rosters HTML footer
 //
 function htmlFooter()
 {
 	global $rosterNavigateTo;
 	global $rosterNavigateVerbiage;
 	global $APU_COPYRIGHT;
 
 	// Display return to another page link/table
 	echo "	<table class=\"table_roster_footer\">\n";
 	echo "	<tbody>\n";
 	echo "		<tr>\n";
 	echo "			<td><div align=\"center\"><span class=\"textdark\">Click <a href=\"" .$rosterNavigateTo ."\">here</a> " .$rosterNavigateVerbiage ."</span></div></td>\n";
 	echo "		</tr>\n";
 	echo "	</tbody>\n";
 	echo "	<tfoot><tr><td colspan=\"1\"></td></tr></tfoot>\n";
 	echo "	</table>\n";
 
 	// Display Copyright
 	echo "<p>" .$APU_COPYRIGHT ."</p>\n";
 
 	// End HTML
 	echo "</div>\n";
 	echo "</body>\n";
 	echo "</html>\n";
 }
 
 //
 // Display VA name in top table
 //
 function vaTable($vaName)
 {
 	echo "	<p>&nbsp;</p>\n";
 	echo "	<table class=\"table_roster_header\">\n";
 	echo "		<tbody>\n";
 	echo "			<tr>\n";
 	echo "				<td><div align=\"center\"><span class=\"textredBLrg\">" .$vaName ."<br/>Pilot Email</span></div></td>\n";
 	echo "			</tr>\n";
 	echo "		</tbody>\n";
 	echo "		<tfoot><tr><td></td></tr></tfoot>\n";
 	echo "	</table>\n";
 	echo "	<p>&nbsp;</p>\n";
}


function displayEmailForm($pilot)
{
	echo "<form name=\"pilotEmailForm\" id=\"pilotEmailForm\" method=\"post\" action=\"include/pilotemail_submit.php\">\n";
	echo "	<table class=\"table_loa\">\n";
	echo "		<caption>E-mail " .$pilot['FIRST_NAME'] ." " .$pilot['LAST_NAME'] ." - " .$pilot['PILOT_ID'] ."</caption>\n";
	echo "		<thead><tr>\n";
	echo "			<th>Information</th>\n";
	echo "			<th>Input</th>\n";
	echo "			<th>Example</th>\n";
	echo "		</tr></thead>\n";
	echo "		<tbody>\n";
	echo "			<tr>\n";
	echo "				<td class=\"tableTextRightRedB\">Your Pilot ID</td>\n";
	echo "				<td class=\"tableTextCenter\"><input name=\"pilotID\" type=\"text\" class=\"editfield\" id=\"pilotID\" size=\"30\" maxlength=\"15\" /></td>\n";
	echo "				<td class=\"textred\">CA2256DFW</td>\n";
	echo "			</tr>\n";
	echo "			<tr>\n";
	echo "				<td class=\"tableTextRightRedB\">Your Password</td>\n";
	echo "				<td class=\"tableTextCenter\"><input name=\"password\" type=\"password\" class=\"editfield\" id=\"password\" size=\"30\" maxlength=\"40\" /></td>\n";
	echo "				<td class=\"textred\">Password</td>\n";
	echo "			</tr>\n";
	echo "			<tr>\n";
	echo "				<td class=\"tableTextCenter\">&nbsp;</td>\n";
	echo "				<td class=\"tableTextCenter\"><hr/></td>\n";
	echo "				<td class=\"tableTextCenter\">&nbsp;</td>\n";
	echo "			</tr>\n";
	echo "			<tr>\n";
	echo "				<td class=\"textdarkRight\">Subject</td>\n";
	echo "				<td class=\"tableTextCenter\"><input name=\"subject\" type=\"text\" class=\"editfield\" id=\"subject\" size=\"30\" maxlength=\"80\" /></td>\n";
	echo "				<td class=\"textdark\">Hey Buddy</td>\n";
	echo "			</tr>\n";
	echo "			<tr>\n";
	echo "				<td class=\"textdarkRight\">Message</td>\n";
	echo "				<td class=\"tableTextCenter\"><textarea name=\"message\" cols=\"50\" rows=\"20\" class=\"editfield\" id=\"message\"></textarea></td>\n";
	echo "				<td class=\"textdark\">Lets fly today!!!\n";
	echo "			</tr>\n";
	echo "				<tr>\n";
	echo "					<td class=\"tableTextCenter\">&nbsp;</td>\n";
	echo "					<td class=\"tableTextCenter\"><input name=\"Submit\" type=\"image\" id=\"Submit\" src=\"img/submit_button.jpg\" alt=\"Submit\" /></td>\n";
	echo "					<td class=\"tableTextCenter\">&nbsp;</td>\n";
	echo "				</tr>\n";
	echo "		</tbody>\n";
	echo "		<tfoot>\n";
	echo "			<tr>\n";
	echo "				<td colspan=\"3\">\n";
	echo "					<span class=\"tableTextLeft\">\n";
	echo "						Your ID and password is required to send this pilot an e-mail.<br/>\n";
	echo "						Any HTML will be stripped from the message except for br and p.<br/>\n";
	echo "						There is a limit of 1000 characters for your message.\n";
	echo "					</span>\n";
	echo "				</td>\n";
	echo "			</tr>\n";
	echo "		</tfoot>\n";
	echo "	</table>\n";
	echo "	<input name=\"emailPilotID\" type=\"hidden\" id=\"emailPilotID\" value=\"" .$pilot['PILOT_ID'] ."\" />\n";
	echo "</form>\n";
}

?>
